﻿Public Class Frm2ClientesNuevos
    Public Function cargarSocios() As Boolean
        'Objeto Roles
        Dim accion As New TipoSocioDAO
        'Tabla temporal de roles
        Dim tabla As DataTable
        tabla = accion.mostrar
        'Comprobar si hay roles
        If tabla Is Nothing Then
            Return False
        Else

            'Trabajar con el control combox
            With cbxTsocio
                'No se permite modificar
                .DataSource = accion.mostrar
                'Fuentes de dtao
                .DropDownStyle = ComboBoxStyle.DropDownList
                'Campo a mostrar
                .DisplayMember = "Tipo"
                'Clave principal
                .ValueMember = "ID_Tipo_Socio"
                'No mostrar ningun rol
                .SelectedIndex = -1
            End With
            Return True
        End If
    End Function
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Me.Close()

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        'Clase Roles
        Dim dato As New Socio
        'Clase Operaciones
        Dim accion As New SocioDAO
        'Asignar los datos

        dato.pNombre = txtNombre.Text
        dato.pDirec = txtDireccion.Text
        dato.pDocu = txtCedula.Text
        dato.pTelefono = txtTelefono.Text
        dato.pEmail = txtEmail.Text
        dato.pContac = txtContacto.Text
        dato.pIdtsocio = cbxTsocio.SelectedValue
        'Agregar registro
            If accion.agregar(dato) Then
                MessageBox.Show("Registro almacenado", "Guardar", MessageBoxButtons.OK, MessageBoxIcon.Information)
            Frm2ClientesMenu.Show()
                Me.Close()
            Else
                MessageBox.Show("No se puede guardar el registro, contacte al administrador", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Warning)
            End If

    End Sub

    Private Sub Frm2ClientesNuevos_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        cargarSocios()

    End Sub
End Class